Copyright: Copyright ¸ 1998 HomeGrown Software
Citation: Author - Paul Warren


Parsecmp Unit

The following items are declared in the Parsecmp unit:

Components

ThgsParser

Types

TOnParseEvent

TParserType


 ThgsParser Component

Properties	Events

Unit

Parsecmp

Description

ThgsParser is a component wrapper around a TCustomParser class which simplifies the use of TCustomParser and its descendants. To use ThgsParser, drop it on a form, set ParserType and write an OnParse event handler. When your program is running pass a stream to ParseStream and it will immediately execute.


ThgsParser_Properties
Properties

ParserType	ParseStream


ParserType Property

Applies To

ThgsParser

Declaration

property ParserType: TParserType;

Description

Set ParserType to one of the enumerated type available.


ParseStream Property

Applies To

ThgsParser

Declaration

property ParseStream: TStream;

Description

ParseStream is a write only property that takes a TStream and immediately executes the parser. Any code in OnParse will be executed.


ThgsParser_Events
Events

OnParse


OnParse Event

Applies To

ThgsParser

Declaration

OnParse: TOnParseEvent

Description

The OnParse event is triggered every time the parser executes.


TOnParseEvent Type

Applies To

ThgsParser

Declaration

TOnParseEvent = procedure(Sender: TObject; Token: char; var Abort: boolean) of object;

Description

TOnParseEvent is the type of the OnParse event. Token is the token returned by the parser and Abort is a variable which when set to true causes the parsing to stop.


TParserType Type

Applies To

ThgsParser

Declaration

TParserType = (ptCSV, ptText, ptPascal, ptEnhPas, ptHtml);

Description

TParserType exumerates the possible parsers.

ptCSV: 	comma seperated values parser

ptText: 	text parser

ptPascal: 	pascal source parser

ptEnhPas: 	enhanced source parser

ptHtml: 	html parser


Newparse Unit

The following items are declared in the Newparse unit:

Components

TCustomParser

TCSVParser

TEnhPasParser

THtmlParser

TPasParser

TTextParser

Types

toCloseTag

toComment

toOpenTag

TParserClass


TCSVParser Component

Methods

Unit

Newparse

Description

TCSVParser is a parser for comma seperated values.


TCSVParser_Methods
Methods

NextToken:	TokenString:


NextToken: Method

Applies To

TCustomParser, TCSVParser, TEnhPasParser, THtmlParser, TTextParser, TPasParser

Declaration

function NextToken: char; override;

Description

NextToken returns the token found during the present iteration. The token returned depends on the type of parser instantiated.


TEnhPasParser Component

Methods

Unit

Newparse

Description

TEnhPasParser is a pascal source parser that is fully aware of pascal syntax including comments.


TEnhPasParser_Methods
Methods

NextToken:	TokenString:


TokenString: Method

Applies To

TCustomParser, TCSVParser, TEnhPasParser, THtmlParser, TTextParser, TPasParser

Declaration

function TokenString: string; override;

Description

TokenString returns the current tokenized string. The actual return depends on the parser instantiated.


THtmlParser Component

Methods

Unit

Newparse

Description

THtmlParser is an Html parser that recognizes Html tags.


THtmlParser_Methods
Methods

NextToken:	TokenString:


Contents
The HomeGrown Parser Component

Parser Component version 1.0 copyright © 1998 HomeGrown Software Development

Welcome to HomeGrown's Parser Component. The following units implement a flexible system of file parsing.

ParseCmp unit

NewParse unit

Example project using HomeGrown's parsing component.


TPasParser Component

Methods

Unit

Newparse

Description

TPasParser is a pascal source parser that is fully aware of pascal syntax except comments.


TTextParser Component

Methods

Unit

Newparse

Description

TTextParser is a parser for plain ASCII text. TTextParser returns tokens for words integers and floating point numbers.


TCustomParser Type

Methods

Unit

Newparse

Description

TCustomParser is the custom base class for a series of parsers including a parser for Html and pascal source.


toCloseTag Type

Applies To

THtmlParser

Declaration

const  toCloseTag = Char(7);

Description

CloseTag is returned from THtmlParser when an Html closing tag is encountered.


toComment Type

Applies To

TCustomParser

Declaration

const  toComment = Char(5);

Description

toComment is returned from TEnhPasParser when a comment is encountered.


toOpenTag Type

Applies To

THtmlParser

Declaration

const  toOpenTag = Char(6);

Description

toOpenTag is returned from THtmlParser when an Html open or stand alone tag is encountered.


TParserClass Type

Unit

NewParse

Declaration

TParserClass = class of TCustomParser;

Description

TParserClass is the class reference for TCustomParser and descendants.